
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/static/X-admin/css/font.css">
    <link rel="stylesheet" href="/static/X-admin/css/xadmin.css">
    <script src="/static/X-admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/X-admin/js/xadmin.js"></script>
    <script src="/static/js/jquery-1.11.1.min.js"></script>

    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-card-body layui-table-body layui-table-main">
    <div><h2>商品信息列表</h2></div>
    <table class="layui-table layui-form">
        <thead>
            <tr>
                <th>男外套</th>
                <th>尺码</th>
                <th>颜色</th>
                <th>金额/元</th>
                <th>操作</th>
            </tr>
            <tr>
                <th>休闲</th>
                <th>s</th>
                <th>蓝色</th>
                <th>100</th>
                <td class="td-manage">
                    <button class="layui-btn layui-btn layui-btn-xs" type="button" data-name1="休闲" >加入购物车</button>
                </td>
            </tr>
            <tr>
                <th>运动</th>
                <th>M</th>
                <th>黑色</th>
                <th>150</th>
                <td class="td-manage">
                    <button class="layui-btn layui-btn layui-btn-xs" type="button" data-name2="运动" >加入购物车</button>
                </td>
            </tr>
            <tr>
                <th>夹克</th>
                <th>L</th>
                <th>灰色</th>
                <th>100</th>
                <td class="td-manage">
                    <button class="layui-btn layui-btn layui-btn-xs" type="button" data-name3="夹克" >加入购物车</button>
                </td>
            </tr>
        </thead>

    </table>

    <div><h2>我的购物车</h2></div>
    <table class="layui-table layui-form">
        <thead>
            <tr>
                <th>男外套</th>
            </tr>

            <?php if($name1!=null){?>
            <tr>
                <th>{$name1}</th>
            </tr>
            <?php }?>

            <?php if($name2!=null){?>
            <tr>
                <th>{$name2}</th>
            </tr>
            <?php }?>

            <?php if($name3!=null){?>
            <tr>
                <th>{$name3}</th>
            </tr>
            <?php }?>
        </thead>

    </table>



</div>
</body>
<script>
    tr=$('tr');
    $('button').click(function(){
        var me=$(this);
        var name1=me.data('name1');
        var name2=me.data('name2');
        var name3=me.data('name3');
        layer.confirm('确认添加到购物车吗？',function(index){
            $.get('{:url("T1/index1")}?name1='+name1+'&name2='+name2+'&name3='+name3,function(resp){
                if(resp.status){
                    layer.msg('添加成功!',{icon:3,time:3000});
                    setTimeout(function(){
                        xadmin.father_reload();
                    },1000)

                //     let html='';
                //     for (var i=0;i<resp.a.length;i++){
                //             html += "<th>"+resp.a+"</th>"+
                //             tr.html(html);
                // }
                }
            });
        });
    });
</script>
</html>